import 'dart:ui';

import 'package:flutter/material.dart';
import 'package:zchope_student/fragment/fuJinFragment.dart';
import 'package:zchope_student/fragment/reMenFragment.dart';

import '../const.dart';

class FirstDetails extends StatefulWidget {
  @override
  _FirstDetailsState createState() => _FirstDetailsState();
}

class _FirstDetailsState extends State<FirstDetails> {
  var selectIndex = 0;
  var fragmentList = <Widget>[];

  var blur = 1.5;

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    fragmentList.add(FuJinFragment());
    fragmentList.add(ReMenFragment());
  }

  Widget _searchTitle() {
    return GestureDetector(
      onTap: () {},
      child: Container(
        height: 35,
        decoration: BoxDecoration(
          color: Const.bar,
          borderRadius: BorderRadius.all(Radius.circular(20.0)),
        ),
        child: Row(
          children: <Widget>[
            SizedBox(
              width: 10,
            ),
            Icon(
              Icons.search,
              color: Colors.white,
            ),
            SizedBox(
              width: 10,
            ),
            Text(
              '搜索',
              style: TextStyle(fontSize: 17, color: Colors.white),
            )
          ],
        ),
      ),
    );
  }

  @override
  Widget build(BuildContext context) {
    return SafeArea(
      child: Scaffold(
        backgroundColor: Const.black,
        appBar: AppBar(
          title: _searchTitle(),
        ),
        body: Container(
            color: Colors.transparent,
            child: SafeArea(
                child: Padding(
              padding: EdgeInsets.only(left: 15, right: 15),
              child: Column(
                children: <Widget>[
                  SizedBox(
                    height: 6,
                  ),
                  Row(
                    children: <Widget>[
                      Expanded(
                          flex: 1,
                          child: GestureDetector(
                            onTap: () {
                              selectIndex = 0;
                              setState(() {});
                            },
                            child: Container(
                              height: 75.0,
                              decoration: BoxDecoration(
                                border: Border.all(
                                    width: 2.0,
                                    color: selectIndex == 0
                                        ? Const.gold
                                        : Colors.transparent),
                                borderRadius:
                                    BorderRadius.all(Radius.circular(8.0)),
                                image: DecorationImage(
                                  fit: BoxFit.fill,
                                  image: AssetImage(
                                    'images/fujin.png',
                                  ),
                                ),
                              ),
                              child: Column(
                                mainAxisAlignment: MainAxisAlignment.center,
                                children: <Widget>[
                                  Text(
                                    '附近',
                                    style: TextStyle(
                                        fontSize: 20, color: Colors.white),
                                  ),
                                  Row(
                                    mainAxisAlignment: MainAxisAlignment.center,
                                    children: <Widget>[
                                      Icon(
                                        Icons.location_on,
                                        color: Colors.white,
                                      ),
                                      Text(
                                        'School Netaive',
                                        style: TextStyle(
                                            fontSize: 14, color: Colors.white),
                                      )
                                    ],
                                  )
                                ],
                              ),
                            ),
                          )),
                      SizedBox(
                        width: 18,
                      ),
                      Expanded(
                          flex: 1,
                          child: GestureDetector(
                            onTap: () {
                              selectIndex = 1;
                              setState(() {});
                            },
                            child: Container(
                              height: 75.0,
                              decoration: BoxDecoration(
                                border: Border.all(
                                    width: 2.0,
                                    color: selectIndex == 1
                                        ? Const.gold
                                        : Colors.transparent),
                                borderRadius:
                                    BorderRadius.all(Radius.circular(8.0)),
                                image: DecorationImage(
                                  fit: BoxFit.fill,
                                  image: AssetImage(
                                    'images/remen.png',
                                  ),
                                ),
                              ),
                              child: Column(
                                mainAxisAlignment: MainAxisAlignment.center,
                                children: <Widget>[
                                  Text(
                                    '热门',
                                    style: TextStyle(
                                        fontSize: 20, color: Colors.white),
                                  ),
                                  Row(
                                    mainAxisAlignment: MainAxisAlignment.center,
                                    children: <Widget>[
                                      Icon(
                                        Icons.star,
                                        color: Const.gold,
                                      ),
                                      Text(
                                        'School Netaive',
                                        style: TextStyle(
                                            fontSize: 14, color: Colors.white),
                                      )
                                    ],
                                  )
                                ],
                              ),
                            ),
                          )),
                    ],
                  ),
                  SizedBox(
                    height: 6,
                  ),
                  Expanded(
                    child: fragmentList[selectIndex],
                  )
                ],
              ),
            ))),
      ),
    );
  }
}
